//
//  YQLeftTableView.m
//  NewRetail
//
//  Created by yuqin on 2019/6/23.
//  Copyright © 2019年 yuqin. All rights reserved.
//

#import "YQLeftTableView.h"
#import "DYLeftSlipManager.h"
#import "YQLeftHeadView.h"
#import "YQLeftTableViewCell.h"
#import "YQManagerWalletVC.h"

@interface YQLeftTableView ()<UITableViewDelegate,UITableViewDataSource>

@property (nonatomic, strong) YQLeftHeadView *leftHeadView;
@property (nonatomic, strong) UITableView *leftTableView;

@end

@implementation YQLeftTableView

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self.headView setHidden:YES];
    
    [self setupLeftView];
    
}

- (void)setupLeftView {
    [self.view addSubview:self.leftHeadView];
    [self.view addSubview:self.leftTableView];
    
    
    [self.leftHeadView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.mas_equalTo(0);
        make.top.mas_equalTo(FIT(50));
        make.height.mas_equalTo(FIT(130));
    }];
    
    [self.leftTableView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(0);
        make.top.equalTo(self.leftHeadView.mas_bottom).mas_equalTo(0);
        make.right.mas_equalTo(0);
        make.height.mas_equalTo(ScreenHeight-FIT(130));
    }];
}

- (YQLeftHeadView *)leftHeadView {
    if (!_leftHeadView) {
        _leftHeadView = [[YQLeftHeadView alloc] init];
        _leftHeadView.backgroundColor = WhiteColor;
    }
    return _leftHeadView;
}

- (UITableView *)leftTableView {
    if (!_leftTableView) {
        _leftTableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
        _leftTableView.delegate = self;
        _leftTableView.dataSource = self;
        _leftTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
        [_leftTableView registerClass:[YQLeftTableViewCell class] forCellReuseIdentifier:YQ_LeftTableViewCell];
    }
    return _leftTableView;
}

#pragma mark - delegate/datasources
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 1;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return YQ_LeftCellHeight;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    YQLeftTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:YQ_LeftTableViewCell forIndexPath:indexPath];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [tableView deselectRowAtIndexPath:indexPath animated:NO];
    [[DYLeftSlipManager sharedManager] dismissLeftView];
    if (self.PushBlock) {
        self.PushBlock();
    }
//    YQ_PUSH([YQManagerWalletVC new]);
}

@end
